<?php if ( ! defined('BASEPATH')) exit('No direct script access allow<ed');

class Laporan extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		//$this->output->enable_profiler(true);
		$this->load->model('mdl_daftar_penduduk');
		$this->load->model('mdl_daftar_keluarga');
		$this->load->model('mdl_daftar_surat');
		$this->load->model('mdl_laporan_keuangan');
	}

	
	public function usia(){
		$data['mhsCount'] =  $this->mdl_daftar_penduduk->getDataCount();
		$data['mhsActCount'] =  $this->mdl_daftar_penduduk->getDataCount('ma');
		$data['klgCount'] =  $this->mdl_daftar_keluarga->getDataCount();
		$data['suratCount'] =  $this->mdl_daftar_surat->getDataCount();
		
		$data['lblDiagram'] = array("2009","2010","2011","2012","2013","2014","2015","2016");
		$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChart($data['lblDiagram']);
		
		$this->load->view('berdasar_usia',$data);
	}

	public function j_kel(){
		
		$data['lblDiagram'] = array("L","W");

		$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChartJK($data['lblDiagram']);
		$data['totalData'] = $this->mdl_daftar_penduduk->getDataChartJK($data['lblDiagram']);
		
		$data['lblDiagram'] = array("Pria","Wanita");
		$data['dataJK'] = $this->mdl_daftar_penduduk->getDataGraph();

		$data['page_title']='Grafik Jenis Kelamin';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='berdasar_j_kel';

		$this->load->view('layout/master',$data);
		//$this->load->view('berdasar_j_kel',$data);
	}
	
	public function pendidikan(){
		
		$data['lblDiagram'] = array("SD","SMP", "SMA", "S1", "S2", "S3");
		$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChartPendidikan($data['lblDiagram']);
		$data['dataJK'] = $this->mdl_daftar_penduduk->getDataGraph();
		
		$data['page_title']='Grafik Tingkat Pendidikan';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='berdasar_pendidikan';

		$this->load->view('layout/master',$data);
		//$this->load->view('berdasar_pendidikan',$data);
	}

	public function agama(){
		
		$data['lblDiagram'] = array("Islam","Kristen", "Hindu", "Budha");
		$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChartAgama($data['lblDiagram']);
		$data['dataJK'] = $this->mdl_daftar_penduduk->getDataGraph();
		
		$data['page_title']='Grafik Agama Dan Kepercayaan';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='berdasar_agama';

		$this->load->view('layout/master',$data);
	}

	public function pekerjaan(){
		
		$data['lblDiagram'] = array("Pelajar","Karyawan", "Wiraswasta", "PNS");
		$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChartPekerjaan($data['lblDiagram']);
		$data['dataJK'] = $this->mdl_daftar_penduduk->getDataGraph();
		
		$data['page_title']='Grafik Jenis Pekerjaan';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='berdasar_pekerjaan';

		$this->load->view('layout/master',$data);
	}

	public function grafik(){
		
		$data['lblDiagram'] = array("January","February", "March", "April", "May", "June", "July", "August", "September","October","November", "December");
		$data['dataNeraca'] = $this->mdl_laporan_keuangan->getDataChartNeraca($data['lblDiagram']);
		$i=0; 
		foreach ($data['dataNeraca'] as $neraca) {
			$data['dataPendapatan'][$i] = $neraca['total_debit'];
			$data['dataBelanja'][$i] = $neraca['total_kredit'];
			$i++;
		}
		
		$data['page_title']='Grafik Pendapatan & Belanja';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='pendapatan_belanja';

		$this->load->view('layout/master',$data);
	}

	public function umur(){
		$data['lblDiagram'] = array("");
		$data['balita'] = $this->mdl_daftar_penduduk->getDataChartUmurB($data['lblDiagram']);
		$data['anak_anak'] = $this->mdl_daftar_penduduk->getDataChartUmurA($data['lblDiagram']);
		$data['remaja'] = $this->mdl_daftar_penduduk->getDataChartUmurR($data['lblDiagram']);
		$data['dewasa'] = $this->mdl_daftar_penduduk->getDataChartUmurD($data['lblDiagram']);
		$data['tua'] = $this->mdl_daftar_penduduk->getDataChartUmurT($data['lblDiagram']);
		//$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChartAgama($data['lblDiagram']);
		$data['dataJK'] = $this->mdl_daftar_penduduk->getDataGraph();
	
		
		$data['page_title']='Grafik Usia Penduduk';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='berdasar_umur';

		$this->load->view('layout/master',$data);
	}

	public function pertumbuhan(){
		$data['lblDiagram'] = array("2009","2010","2011","2012","2013","2014","2015", "2016");
		$data['dataDiagram'] = $this->mdl_daftar_penduduk->getDataChart();
		//$data['dataJK'] = $this->mdl_daftar_penduduk->getDataGraph();
		$data['perTahun'][0] = 0;
		$i=0; 
		foreach ($data['dataDiagram'] as $dataTahun) {
			$thn_daftar = $dataTahun['thn_daftar'];
			$total      = $dataTahun['jumlah'];
			if($i>0){
				$data['perTahun'][$i] = $data['perTahun'][$i-1] + $total;
			}else{
				$data['perTahun'][0] = $total;
			}
			$i++;
		}

		$data['page_title']='Grafik Pertumbuhan Penduduk';
		$data['page_icon']='icon-bar-chart';
		$data['page_content']='berdasar_umur';

		$this->load->view('layout/master',$data);	
	}
}